<template>
    <div>

        <el-table
        :data="data"
        stripe
        v-loading="loading"

        >
            <el-table-column
                v-for="(item, key) in columns"
                :key="key"
                :prop="item.value"
                :label="item.label"
                :width="item.width || ''"
            >
                <template  slot-scope="scope">
                    <slot v-if="item.scope" :name="item.scope" :row="scope.row"></slot>
                    <template v-else>{{ scope.row[item.value] }}</template>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-if="total"
            :total="total" 
            background="#409eff"></pagination>
    </div>
</template>

<script>
    export default {
        name: 'r-table',
        props: {
            columns: {
                type: Array,
                required: true,
            },
            data: {
                type: Array,
                required: true
            },
            loading: {
                type: Boolean,
                required: false
            },
            total: {
                type: Number,
                required: false,
                default: 0
            }
        },
        methods: {
            normalRender (row, column, cellValue) {
                return cellValue
            }
        },
        created () {
            console.log(this.data)
        }
    }
</script>